using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class NormalPanel : SingleBase<NormalPanel>
{
    public bool IsOK;
    public Button ButtonTrue;
    public Button ButtonFalse;
    public RectTransform RectTransform;
    public RectTransform FallPos;
    public RectTransform FailurePos;

    public void Awake()
    {
        ButtonTrue.onClick.AddListener(() => {
            SetEffObj(true);
        });
        ButtonFalse.onClick.AddListener(() => 
        {  SetEffObj(false); });
    }

    public void SetEffObj(bool IsOK)
    {
        string ResourcesLoad = IsOK ? "Cat_Fall" : "Cat_FAILURE";
        RectTransform transform = IsOK ? FallPos : FailurePos; 
        GameObject obj = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Obj/"+ResourcesLoad));
        obj.transform.SetParent(transform);
        RectTransform Tmp = obj.GetComponent<RectTransform>();
        Tmp.localPosition = RectTransform.localPosition;
        Tmp.localScale = Vector3.one;
    }
}
